//
//  ShaidanCell.m
//  YYPHSpeedJump
//
//  Created by sujiang on 15/12/23.
//  Copyright © 2015年 sujiang. All rights reserved.
//

#import "ShaidanCell.h"

@implementation ShaidanCell

- (void)awakeFromNib {
    // Initialization code
    self.imageView3.contentMode = UIViewContentModeScaleAspectFit;
    self.imageView2.contentMode = UIViewContentModeScaleAspectFit;
    self.imageView1.contentMode = UIViewContentModeScaleAspectFit;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(MyshareModel *)model
{
    [self.goodImage sd_setImageWithURL:[NSURL URLWithString:model.comm_img_url] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];
    self.goodName.text = model.name;
    self.oldPrice.text =[NSString stringWithFormat:@"原价：￥%@",model.original_price];
    self.successPrice.text = [NSString stringWithFormat:@"￥交易价：%@",model.buy_price];
    self.sparePrice.text = [NSString stringWithFormat:@"省：￥%ld",model.original_price.integerValue-model.buy_price.integerValue];
    self.joinPerson.text = [NSString stringWithFormat:@"竞价人数：%@",model.up_users];
    NSArray *array = [model.img_url_list componentsSeparatedByString:@";"];
    if (array.count == 1) {
        [self.imageView1 sd_setImageWithURL:[NSURL URLWithString:array[0]] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];
    } else if (array.count == 2) {
        [self.imageView1 sd_setImageWithURL:[NSURL URLWithString:array[0]] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];
        [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:array[1]] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];

    } else {
        [self.imageView1 sd_setImageWithURL:[NSURL URLWithString:array[0]] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];
        [self.imageView2 sd_setImageWithURL:[NSURL URLWithString:array[1]] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];
        [self.imageView3 sd_setImageWithURL:[NSURL URLWithString:array[2]] placeholderImage:[UIImage imageNamed:@"tu-xiao"]];
 
    }
    
    
        NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:model.comment];
        NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
    
        [paragraphStyle setLineSpacing:7.5]; //调整行间距
    
        [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [model.comment length])];
       // self.titleLb.attributedText = attributedString;
    
    
}

+ (CGFloat)heightForText:(NSString *)text
{
    NSDictionary *dic = [NSDictionary dictionaryWithObject:[UIFont systemFontOfSize:12] forKey:NSFontAttributeName];
    CGRect frame = [text boundingRectWithSize:CGSizeMake(290 * kWidthScale, 10000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:dic context:nil];
    return frame.size.height;
}



@end
